package adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import bean.AllBean;
import jiyun.com.yiyanmeng.R;

/**
 * Created by 裘翔 on 2019/11/7.
 */

public class AllsAdaper extends RecyclerView.Adapter<AllsAdaper.ViewHolder>{
    private Context context;
    private ArrayList<AllBean.CourseBean> list;

    public AllsAdaper(Context context, ArrayList<AllBean.CourseBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public AllsAdaper.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.books_item, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull AllsAdaper.ViewHolder holder, int position) {
        Glide.with(context).load(list.get(position).getPic()).into(holder.iv);
        holder.tvname.setText(list.get(position).getName());
        holder.tvmonery.setText(list.get(position).getClass_hour());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView iv;
        TextView tvname;
        TextView tvmonery;
        public ViewHolder(View itemView) {
            super(itemView);
            iv=itemView.findViewById(R.id.books_iv);
            tvname=itemView.findViewById(R.id.books_name);
            tvmonery=itemView.findViewById(R.id.books_monery);
        }
    }
}
